local skynet = require 'skynet'
require 'skynet.manager'

require 'nggs.base.const'
local inspect = require 'nggs.base.inspect'

skynet.error('test1 started')

skynet.start(
    function()
        skynet.timeout(
            300,
            function()
                skynet.error('test1 end')
                skynet.sleep(0)
                skynet.abort()
            end
        )

        local const = {
            [1] = {
                Id = 1,
                Level = 1,
                Skill = {4, 1},
                Type = 0,
                Attack = 10,
                Defence = 10,
                EnergyRecoverSpeed = 20,
                MaxLeadSoldierNum = 100,
                Suitability = 1,
                HpAddPermillage = 0,
                AttackAddPermillage = 0,
                SpeedAddPermillage = 0
            },
            [2] = {
                Id = 2,
                Level = 1,
                Skill = {4, 2},
                Type = 0,
                Attack = 10,
                Defence = 10,
                EnergyRecoverSpeed = 20,
                MaxLeadSoldierNum = 100,
                Suitability = 1,
                HpAddPermillage = 0,
                AttackAddPermillage = 0,
                SpeedAddPermillage = 0
            },
            [3] = {
                Id = 3,
                Level = 1,
                Skill = {4, 3},
                Type = 0,
                Attack = 10,
                Defence = 10,
                EnergyRecoverSpeed = 20,
                MaxLeadSoldierNum = 100,
                Suitability = 1,
                HpAddPermillage = 0,
                AttackAddPermillage = 0,
                SpeedAddPermillage = 0
            },
            [5] = {
                Id = 5,
                Level = 1,
                Skill = {4},
                Type = 0,
                Attack = 10,
                Defence = 10,
                EnergyRecoverSpeed = 20,
                MaxLeadSoldierNum = 100,
                Suitability = 1,
                HpAddPermillage = 0,
                AttackAddPermillage = 0,
                SpeedAddPermillage = 0
            }
        }

        const = Const(const)

        -- print(inspect(const))
        -- print(next(const))
        -- print(#const)
        -- for k, v in pairs(const) do
        --     print(k)
        --     -- print(inspect(v))
        -- end

        -- const[1] = {}

        local e = const[1]
        -- print(inspect(e))

        -- print(inspect(e.Skill))
        -- print(next(e.Skill))
        -- print(#e.Skill)

        for _, skillID in pairs(e.Skill) do
            print(skillID)
        end

        for i = #e.Skill, 1, -1 do
            print(e.Skill[i])
        end

        -- e.Attack = 1
        -- e.Skill = {}
        -- e.Skill[1] = 1
    end
)
